<template>
  <div class="container">
    <h3>职位认证</h3>
    <el-form ref="form" :model="form" label-width="130px">
      <el-form-item label="姓名">
        <el-input v-model="form.name" style="width:300px;display:block"></el-input>
      </el-form-item>
      <el-form-item label="性别">
        <el-radio-group v-model="form.sex">
          <el-radio label="男" value="0"></el-radio>
          <el-radio label="女" value="1"></el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="公司">
        <el-input v-model="form.company" style="width:300px;display:block"></el-input>
      </el-form-item>
      <el-form-item label="职位">
        <el-input v-model="form.job" style="width:300px;display:block"></el-input>
        <!-- <el-select v-model="form.region" placeholder="请选择职位">
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select> -->
      </el-form-item>
      <el-form-item label="工牌,名片,其他">
        <el-upload
          class="upload-demo"
          action="http://127.0.0.1:7038/article/company/upload"
          :on-preview="handlePreview"
          :on-remove="handleRemove"
          :before-remove="beforeRemove"
          multiple
          :limit="3"
          :data="{ id: userId }"
          :on-exceed="handleExceed"
          :file-list="fileList"
        >
          <el-button size="small" type="primary">点击上传</el-button>
          <div slot="tip" class="el-upload__tip">
            （注意图片大小不要超过2MB哦）
          </div>
        </el-upload>
        <el-dialog :visible.sync="dialogVisible">
            <img width="100%" :src="form.img" alt="">
          </el-dialog>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import {
  getCompany,
  updateCompany
} from "@/api/article/MyInfo";
export default {
    name:'Education',
    data() {
      return {
        userId:'',
        form:{
          sex:0,
          img:'',
          job:'',
          company:'',
          name:''
        },
        fileList: []
      };
    },
    created() {
      this.userId=this.$route.query.id
      getCompany(this.userId).then(response=>{
        if(response.data.data!=null){
          this.form=response.data.data
        }
        
      })
    },
    methods: {
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      },
      handleExceed(files, fileList) {
        this.$message.warning(`当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
      },
      beforeRemove(file, fileList) {
        return this.$confirm(`确定移除 ${ file.name }？`);
      },
      onSubmit(){
        updateCompany(this.form).then(response=>{
          
        })
      }
    }
  }
</script>
<style>
h3{
    color: grey;
    font-size: 30px;
    margin-left: 88px
}
.container{
    margin-left: 180px;
}

</style>
